
import * as types from '../types'

import {Map} from 'immutable'

const reducer = (state = Map({
    count: 100
}), actions) => {

    switch (actions.type) {
        case types.ADD:

            // return { ...state, count: state.count + 1 }
            return state.set('count', state.get('count') + 1)
        case types.REDUCE:

            // return { ...state, count: state.count - 1 }
            return state.set('count', state.get('count') - 1)
        case types.ADDNUM:

            // return { ...state, count: state.count + actions.payload }
            return state.set('count', state.get('count') + actions.payload)
        case types.REDUCENUM:

            // return { ...state, count: state.count - actions.payload }

            return state.set('count', state.get('count') - actions.payload)
        default:

            return state    
        
    }
}

export default reducer